import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:sleep/help_style.dart';
import 'package:sleep/provider/wave_deatil_provider/pluse_detail_provider.dart';

class DeatilHeart extends ConsumerWidget {
  const DeatilHeart({super.key});

  heart(
    IconData iconData,
    String title,
    String content,
  ) {
    return Row(
      children: [
        CircleAvatar(
            backgroundColor: iconColors[2],
            child: Icon(
              iconData,
              color: iconColors[3],
            )),
        SizedBox(width: HelpStyle.margin),
        Column(
          children: [
            Text(content, style: HelpStyle.contextStyle),
            Text(title, style: HelpStyle.smallStyle),
          ],
        ),
      ],
    );
  }

  Widget titles() {
    return Row(
      children: [
        Icon(
          Icons.favorite,
          color: iconColors[3],
          size: 16,
        ),
        SizedBox(width: HelpStyle.cellMargin),
        Text(
          "pulse Message",
          style: HelpStyle.contextStyle,
        ),
      ],
    );
  }

  @override
  Widget build(BuildContext context, ref) {
    final pulse = ref.watch(pulseDetailProvider);
    return Container(
      padding: const EdgeInsets.all(12),
      decoration: HelpStyle.decoration,
      child: Column(
        children: [
          titles(),
          SizedBox(height: HelpStyle.margin),
          Row(
            children: [
              Expanded(child: heart(Icons.monitor_heart, "hrv", pulse.hrv)),
              Expanded(child: heart(Icons.favorite, "si", pulse.si)),
            ],
          ),
          SizedBox(height: HelpStyle.margin),
          Row(
            children: [
              Expanded(child: heart(Icons.monitor_heart, "pwv", pulse.pwv)),
              Expanded(child: heart(Icons.favorite, "bpm", pulse.bpm)),
            ],
          ),
        ],
      ),
    );
  }
}
